import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue'),
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import(/* webpackChunkName: "about" */ '../views/Home.vue'),
    children: [
      {
        path: '/view/toBranch',
        name: 'branch',
        component: () => import(/* webpackChunkName: "about" */ '../views/branch/Branch.vue')
      },
      {
        path: '/view/toMenu',
        name: 'menu',
        component: () => import(/* webpackChunkName: "about" */ '../views/menu/Menu.vue')
      },
      {
        path: '/view/toStaff',
        name: 'menu',
        component: () => import(/* webpackChunkName: "about" */ '../views/staff/Staff.vue')
      },
      {
        path: '/view/toDepartment',
        name: 'department',
        component: () => import(/* webpackChunkName: "about" */ '../views/department/Department.vue')
      },
      {
        path: '/view/toRole',
        name: 'position',
        component: () => import(/* webpackChunkName: "about" */ '../views/position/Position.vue')
      },
      {
        path: '/view/toQuitBranch',
        name: 'quitBranch',
        component: () => import(/* webpackChunkName: "about" */ '../views/branch/QuitBranch.vue')
      },

    ]
  },
]

const router = new VueRouter({
  mode:'history',
  routes
})

//修改重复路由的异常显示
const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

export default router
